﻿using System.Web;
using System.Web.Mvc;
using Json.Net;

namespace IterationLife.Extensions.MvcApi
{
    public class MvcApiResult<TData> : ActionResult
    {
        public TData Data { get; set; }

        public string Code { get; set; }

        public string Message { get; set; }


        public override void ExecuteResult(ControllerContext context)
        {
            HttpResponseBase response = context.HttpContext.Response;
            response.ContentType = "application/json";
            response.Write(JsonConvert.SerializeObject(this));
        }
    }
}
